package com.vcommon.core.logging.publishers
{
import com.vcommon.core.logging.ILogPublisher;
import com.vcommon.core.logging.LogRecord;

public class SaveLogPublisher extends AbstractLogPublisher implements ILogPublisher
{
    static public const ALL_LOG:Array = [];
    
    public function SaveLogPublisher()
    {
    }
    
    override public function publish(logRecord:LogRecord):void
    {
        if (isLoggable(logRecord))
        {
            ALL_LOG.push(format(logRecord));
        }
    }
    
    private function format(logRecord:LogRecord):String
    {
        var formatted:String;
        formatted = "[" + logRecord.getLevel().name + "]\t" + 
            logRecord.getDate().toTimeString().slice(0, 8) + " " + 
            logRecord.getMessage();
        return formatted;
    }
}
}